package main

import (
	"encoding/json"
)

func jsonDecoder(raw []byte) (TrustMQMessage, error) {
	msg := TrustMQMessage{AppName: "", PhoneNum: "", TokenCode: ""}

	var dat map[string]interface{}
	err := json.Unmarshal(raw, &dat)
	println("raw ===> ", raw)
	println("解析===>")
	println("dat ===>", dat)
	if err != nil {
		return msg, err
	}
	d, _ := json.Marshal(dat)
	println("d ====> ", d)
	msg.AppName = dat["AppName"].(string)
	msg.PhoneNum = dat["PhoneNum"].(string)
	msg.TokenCode = dat["TokenCode"].(string)
	msg.TrustType = dat["TrustType"].(string)
	msg.DeviceModel = dat["DeviceModel"].(string)
	return msg, err
}
